package com.sunxd.vue.infrastructure.adapter.db.repository;

import com.sunxd.vue.bean.response.InteractiveActivityInfo;
import com.sunxd.vue.domain.bean.domain.interactive.InteractiveActivity;
import com.sunxd.vue.domain.repository.InteractiveActivityRepository;
import com.sunxd.vue.infrastructure.adapter.db.base.Paging;
import com.sunxd.vue.infrastructure.adapter.db.dao.InteractiveActivityDao;
import com.sunxd.vue.infrastructure.adapter.db.mapping.InteractiveActivityMapping;
import com.sunxd.vue.infrastructure.adapter.db.po.InteractiveActivityPO;
import com.sunxd.vue.infrastructure.utils.PagingUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author sun.xd
 * @description: description
 * @date 2024/4/25 11:43
 */
@Component
@RequiredArgsConstructor
public class InteractiveActivityRepositoryImpl implements InteractiveActivityRepository {

    private final InteractiveActivityDao dao;

    @Override
    public Boolean create(InteractiveActivity param) {
        return dao.create(InteractiveActivityMapping.CONVERTER.do2create(param));
    }

    @Override
    public Boolean update(InteractiveActivity param) {
        return dao.update(InteractiveActivityMapping.CONVERTER.do2po(param));
    }

    @Override
    public InteractiveActivity detail(InteractiveActivity param) {
        InteractiveActivityPO byUuid = dao.findByUuid(param.getUuid());
        return InteractiveActivityMapping.CONVERTER.po2do(byUuid);
    }

    @Override
    public Paging<InteractiveActivity> page(Map<String, Object> param) {
        return PagingUtil.toPaging(dao.paging(param), InteractiveActivityMapping.CONVERTER::po2do);
    }
}
